using System;
using System.IO;
using System.Web.UI;
using Framework.Library.Base.Extensions;
using Framework.Library.Core.Config;
using Framework.Library.Base.Helper;

namespace Framework.Library.Base.Base
{
    public class BaseControl : UserControl
    {
        public ConfigHelper cfg
        {
            get { return new ConfigHelper(); }
        }

        public LanguageHelper Localization
        {
            get { return LanguageHelper.Language; }
        }

        protected int currentUserId
        {
            get
            {
                int i = 0;
                if (Session.GetUser() != null)
                {
                    if (Session.GetUser().TYPE == (int)UserType.govn)
                        i = Session.GetUser().DESTUSERID;
                    else
                        i = Session.GetUser().USERID;
                }
                return i;
            }
        }

        protected string currentUserName
        {
            get
            {
                string username = string.Empty;
                if (Session.GetUser() != null)
                {
                    username = Session.GetUser().USERNAME;
                }
                return username;
            }
        }

        public string UploadPath
        {
            get
            {
                string userUploadPath = cfg.UploadDir.VALUE + Session.GetUser().USERID + "/" + Session.WorkingPortal().PORTALID + "/";
                if (!Directory.Exists(Server.MapPath(userUploadPath)))
                    Directory.CreateDirectory(Server.MapPath(userUploadPath));
                return userUploadPath;
            }
        }

        public string ImagePath
        {
            get { return Configurations.ROOTDIR + "Templates/" + Session.CurrentPortal(Configurations.PORTALID).LAYOUT + "/Resources/"; }
        }
    }
}